<template>
    <span v-if="status == true" @click="add(id)">
        加入书架
    </span>
    <span v-else>已在书架</span>
</template>

<script>
export default {
    props:["status","id"],
    methods:{
        add(id){
            if(localStorage.id){
                let status = !this.status
                this.$bus.$emit("add",{id,status})
            }else{
                alert("请登录");
                this.$router.push({path:"/login"})
            }
            
        }
    }
}
</script>

<style scoped>
    span{
        border:1px solid blue;
        color:blue;
        padding:5px 10px;
        cursor: pointer;
    }
</style>
